package tech.eyao.hs60x.user.controller;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import tech.eyao.hs60x.awareUtil.CommonServiceUtil;
import tech.eyao.hs60x.dto.BaseResult;
import tech.eyao.hs60x.enums.ExceptionCodeEnum;

/**
 * @author fengjianchao 通用服务
 */
@Api("通用服务")
@RestController
@RequestMapping("/open/common")
public class CommonUtilController {

    private static final Logger logger = LoggerFactory.getLogger(CommonUtilController.class);

    @RequestMapping(value = "/weather", method = RequestMethod.GET)
    @ApiOperation(value = "获取天气接口", notes = "")
    public @ResponseBody Object getWeather(@ApiParam(value = "当前城市") String city) {
        logger.info(">>getWeather start city:" + city);
        if (StringUtils.isBlank(city)) {
            return BaseResult.isFailure(ExceptionCodeEnum.ERROR_PARAMERROR.getCode(),
                    ExceptionCodeEnum.ERROR_PARAMERROR.getMessage());

        }
        return CommonServiceUtil.getInstance().getWeather(city);

    }

}
